#include <QDebug>
#include <iostream>
#include <string>

#include "client.h"
#include "protocol.h"

Client::Client(QObject *parent)
{
    this->setParent(parent);
    this->_tcpClient = new TCPClient(this);
}

void Client::connectToHost(QString ip, short port)
{
    this->_tcpClient->getSocket().abort();
    this->_tcpClient->getSocket().connectToHost(ip, port);

    qDebug() << ip;
}

void Client::disconnectFromHost()
{
    this->_tcpClient->getSocket().disconnectFromHost();
}

void Client::logout()
{
    CSProtocol::Logout *log = new CSProtocol::Logout();
    log->sendTreat(*this->_tcpClient);
}

void Client::reg()
{
    CSProtocol::Register *reg = new CSProtocol::Register();
    reg->sendTreat(*this->_tcpClient);
}

void Client::authenticate()
{
    CSProtocol::Login *log = new CSProtocol::Login();
    log->sendTreat(*this->_tcpClient);
}

void Client::addContact()
{
    CSProtocol::AddContact *c = new CSProtocol::AddContact();
    c->sendTreat(*this->_tcpClient);
}
